package cn.rengy.tpa.wxmp.token.ticket;

import org.apache.commons.lang3.StringUtils;

import com.alibaba.fastjson.JSONObject;

public class TicketResponse {

	private int errcode;
	
	private String errmsg;
	
	private String ticket;//获取到的凭证
	
	private int expires_in;//凭证有效时间，单位：秒
	public TicketResponse(){
		
	}
	public TicketResponse(String httpResult){
		JSONObject jsonObject = JSONObject.parseObject(httpResult);
		errcode=jsonObject.getIntValue("errcode");
		errmsg=jsonObject.getString("errmsg");
		ticket=jsonObject.getString("ticket");
		expires_in=jsonObject.getIntValue("expires_in");
	}
	
	public boolean isSuccess(){
		if(errcode==0&&StringUtils.isNotBlank(ticket)&&expires_in>0){
			return true;
		}
		return false;
	}
	public int getErrcode() {
		return errcode;
	}

	public void setErrcode(int errcode) {
		this.errcode = errcode;
	}

	public String getErrmsg() {
		return errmsg;
	}

	public void setErrmsg(String errmsg) {
		this.errmsg = errmsg;
	}

	public String getTicket() {
		return ticket;
	}

	public void setTicket(String ticket) {
		this.ticket = ticket;
	}

	public int getExpires_in() {
		return expires_in;
	}

	public void setExpires_in(int expires_in) {
		this.expires_in = expires_in;
	}

	
}
